********************************************************************************
******************************* TABLES AND FIGURES *****************************
************************************* for **************************************
****************************** A FIELD OF HER OWN ******************************
********************************************************************************
** CREATED BY: ALEXANDER FERTIG
** CREATED ON: 16 FEB 2022

estimates clear


use "$clean/regfile_May2021.dta", clear
set scheme s1color

* shorten variable names
rename form7_femhoh_nomale f7_fhoh_nm
rename riceinc_fem_ln rcinc_fem_ln
rename nonaginc_fem_ln nai_f_ln
rename agency_ag_index11 a_ag_ind11
rename agency_exp_index11 a_ex_ind11
rename Wtake_ag_index1 wt_ag_ind1
rename Hgive_ag_index1 hg_ag_ind1
rename WHagree_ag_index1 wha_ag_ind1
rename Wtake_exp_index1 wt_ex_ind1
rename Hgive_exp_index1 hg_ex_ind1
rename WHagree_exp_index1 wha_ex_ind1
rename poliknow_minister_correct pknow_min_c
rename poliknow_vta_correct pknow_vta_c

* create new vars
gen aginc_ln=ln(1+aginc)
lab var aginc_ln "Log of Total Agricultural Revenue from all Plots"
gen voteint_nat=(vote_national==1)
gen dem_pref=(demo_condition==1)

* change revenue vars to $1,000
foreach var of varlist aginc_fem riceinc_fem nonaginc_fem aginc riceinc{
	replace `var'=`var'/1000
	local y: variable label `var'
	label var `var' "`y' (1000s MMK)"
}

* agency vars should only be defined for women
# delimit;
local agencyvars
	wt_ag_ind1
	hg_ag_ind1
	wha_ag_ind1
	wt_ex_ind1
	hg_ex_ind1
	wha_ex_ind1;
# delimit cr
foreach var in `agencyvars'{
    replace `var'=. if male==1
}


****** Make table of agency index components

lab var agency_ag_land "Wife Involved in Decisions About Selling/Renting/Buying Land"
lab var agency_ag_stock "Wife Involved in Decisions About Livestock Raising"
lab var agency_ag_gard "Wife Involved in Decisions About Gardening"
lab var agency_ag_labor "Wife Involved in Decisions About Hiring Agricultural Labor"
lab var agency_ag_crops "Wife Involved in Decisions About Choosing Crops"
lab var agency_exp_childcare "Wife Involved in Decisions About Child Care"
lab var agency_exp_health "Wife Involved in Decisions About Healthcare"
lab var agency_exp_cook "Wife Involved in Decisions About Cooking"
lab var agency_exp_educ "Wife Involved in Decisions About Expenditures for Education"
lab var agency_exp_childoth "Wife Involved in Decisions About other Expenditures for Children"
lab var agency_exp_food "Wife Involved in Decisions About Expenditures for Food Consumption"
lab var agency_exp_rel "Wife Involved in Decisions About Religious Expenditures"
lab var agency_exp_fert "Wife Involved in Decisions About Fertility"


# delimit ;
local ind_comp
	agency_ag_land
	agency_ag_stock
	agency_ag_gard
	agency_ag_labor
	agency_ag_crops
	agency_exp_childcare
	agency_exp_health
	agency_exp_cook
	agency_exp_educ
	agency_exp_childoth
	agency_exp_food
	agency_exp_rel
	agency_exp_fert;
# delimit cr
	
estpost tabstat `ind_comp' if land_yn==1, by(male) statistics(mean sd) ///
	columns(statistics)

esttab . using "$latex/ind_comp.tex", replace ///
	refcat(agency_ag_land "\textbf{Panel A: Agricultural Decisions Index} \\ \bottomrule \vspace{-1em}" ///
	agency_exp_childcare ///
	"\toprule \\[-.2in] \textbf{Panel B: Expenditure Decisions Index} \\ \bottomrule \vspace{-1em}", ///
	nolabel) main(mean) aux(sd) nostar unstack label nonumbers nonotes gaps ///
	noobs booktabs compress long varwidth(40) f wrap nomtitle



****** Make Histogram of Landholding

twoway (histogram landsize if bothreportland==1 & male==0 & landsize<=30, color(orange_red) start(0) width(1)) ///
 (histogram landsize if bothreportland==1 & male==1 & landsize<=30, fcolor(none) lcolor(green) start(0) width(1)), ///
	legend(order(1 "Wife" 2 "Husband"))
graph export "$latex/land_histogram_Feb2023.png", replace



*************************************************************


local a=10
* set cutoff as close to 10 as possible
local aplus=10.00000000000001


****McCrary test at different cutoffs

local amc=10.00001
local five=`amc'-5
local fifteen=`amc'+5
local twenty=`amc'+10

DCdensity landsize if landsize>0 & landsize<30 & bothreportland==1 & male==0, breakpoint(`five') generate(Xj Yj r0 fhat se_fhat)
graph rename Graph graph1
drop Xj Yj r0 fhat se_fhat

DCdensity landsize if landsize>0 & landsize<30 & bothreportland==1 & male==0, breakpoint(`amc') generate(Xj Yj r0 fhat se_fhat) 
graph rename Graph graph2
drop Xj Yj r0 fhat se_fhat

DCdensity landsize if landsize>0 & landsize<30 & bothreportland==1 & male==0, breakpoint(`fifteen') generate(Xj Yj r0 fhat se_fhat) 
graph rename Graph graph3
drop Xj Yj r0 fhat se_fhat

DCdensity landsize if landsize>0 & landsize<30 & bothreportland==1 & male==0, breakpoint(`twenty') generate(Xj Yj r0 fhat se_fhat) 
graph rename Graph graph4
drop Xj Yj r0 fhat se_fhat

graph combine graph1 graph2 graph3 graph4, rows(2)
graph export "$latex/mccrary_mult.png", replace
graph drop _all

*****************************************
** Tables 0: Rounders vs. non-Rounders **
*****************************************

# delimit ;
local roundvars
	age
	educ1
	educ2
	educ3
	hh_size;
# delimit cr

* generate dummy for rounders
gen rounder=landsize==10
replace rounder=. if landsize<=9 | landsize>=11

estpost ttest `roundvars', by(rounder)
sum age if rounder==0
local n_0=r(N)
sum age if rounder==1
local n_1=r(N)
estadd scalar obs_0=`n_0'
estadd scalar obs_1=`n_1'

esttab using "$latex/rounders.tex", replace ///
	cells("mu_1(fmt(2)) mu_2(fmt(2)) b(star fmt(3))" ". . se(par fmt(3))") ///
	collabels("Non-Rounders" "Rounders" "Diff.") ///
	star(* 0.10 ** 0.05 *** 0.01) wrap label booktabs nonum nonotes gaps ///
	compress varwidth(40) f nomtitle noobs ///
	stats(obs_0 obs_1, layout("@ @") labels("Observations") fmt(0 0))


**********************************
** Tables 1: Summary Statistics **
**********************************

lab var form7_femhoh "Household has at least 1 Form 7 in Wife's name (joint)"
lab var f7_fhoh_nm "HH has at least 1 Form 7 in Wife's name (excl. and no other man)"
lab var loan_num_fem "Number of Loans in Wife's Name (Land Collateralized)"
lab var loan_num_male "Number of Loans in Husband's Name (Land Collateralized)"
lab var nonaginc_fem "Total non-Agricultural Income from Wife (1000s MMK)"

# delimit ;
local sumstats1
	age
	educ1
	educ2
	educ3
	hh_size
	nplot
	form7_tot
	form7_femhoh
	f7_fhoh_nm;
local sumstats2
	loan_num_fem
	loan_num_male
	aginc_fem
	riceinc_fem
	nonaginc_fem
	aginc
	riceinc
	a_ag_ind11
	a_ex_ind11;
local sumstats3
	wt_ag_ind1
	hg_ag_ind1
	wha_ag_ind1
	wt_ex_ind1
	hg_ex_ind1
	wha_ex_ind1;
# delimit cr

estpost tabstat `sumstats1' if land_yn==1, by(male) statistics(mean sd) ///
	columns(statistics)

esttab . using "$latex/sumstats1.tex", replace ///
	refcat(age "\textbf{Panel A: Demographics} \\ \bottomrule \vspace{-1em}" ///
	nplot ///
	"\toprule \\[-.2in] \textbf{Panel B: Formal Property Rights} \\ \bottomrule \vspace{-1em}", ///
	nolabel) main(mean 3) aux(sd 3) nostar unstack label nonumbers nonotes gaps ///
	noobs booktabs compress long varwidth(40) f wrap nomtitle
	
estpost tabstat `sumstats2' if land_yn==1, statistics(mean sd) ///
	columns(statistics)
est store A
estpost tabstat `sumstats2' if land_yn==1 & male==0, statistics(mean sd) ///
	columns(statistics)
est store B
estpost tabstat `sumstats2' if land_yn==1 & male==1, statistics(mean sd) ///
	columns(statistics)
est store C

esttab A B C using "$latex/sumstats2.tex", replace ///
	refcat(loan_num_fem "\textbf{Panel A: Economic Outcomes} \\ \bottomrule \vspace{-1em}" a_ag_ind11 ///
	"\toprule \\[-.2in] \textbf{Panel B: Women's Agency} \\ \bottomrule \vspace{-1em}", ///
	nolabel) main(mean 3) aux(sd 3) nostar unstack label nonumbers nonotes gaps ///
	noobs booktabs compress long varwidth(40) f wrap noeqlines ///
	mtitle("Total" "Wife" "Husband")

estpost tabstat `sumstats3' if land_yn==1 & male==0, statistics(mean sd) ///
		columns(statistics)
est store D

esttab D using "$latex/sumstats2.tex", append ///
	main(mean 3) aux(sd 3) nostar unstack label nonumbers nonotes gaps noobs ///
	booktabs compress long varwidth(40) f wrap nomtitle	nolines



*********************************
** Table 3: RDD Land Ownership **
*********************************


# delimit ;
local balvars
	age
	educ1
	educ2
	educ3
	hh_size;
# delimit cr

# delimit ;
local landvars
	nplot
	form7_tot
	form7_femhoh
	f7_fhoh_nm;
# delimit cr

foreach var in `landvars'{
	forval s=0/1{
		
		replace `var'=. if mi(`var')
		
		rdrobust `var' landsize if bothreportland==1 & ///
			male==`s', c(`aplus') all
		local n_l=e(N_h_l)
		local n_r=e(N_h_r)
		local l=e(h_l)
		local r=e(h_r)
		local wl=`aplus'-`l'
		local wr=`aplus'+`r'
		eststo land_`a'_`s'_`var'
		sum `var' if landsize<`aplus' & landsize>=`aplus'-`l' & ///
			bothreportland==1 & male==`s'
		local land_`a'_`s'_mean=r(mean)
		local land_`a'_`s'_sample=`n_l'+`n_r'
		local land_`a'_`s'_bw=`l'
		rdrandinf `var' landsize if bothreportland==1 & male==`s', cutoff(`aplus') wl(`wl') wr(`wr') p(1) kernel(triangular)
		local ri_p=r(randpval)
		estadd scalar mean_below=`land_`a'_`s'_mean': land_`a'_`s'_`var'
		estadd scalar sampsi=`land_`a'_`s'_sample': land_`a'_`s'_`var'
		estadd scalar bandwidth=`land_`a'_`s'_bw': land_`a'_`s'_`var'
		estadd scalar randinf=`ri_p': land_`a'_`s'_`var'
		
		rdrobust `var' landsize if bothreportland==1 & ///
			male==`s', c(`aplus') covs(educ3 hh_size) all
		eststo land_c_`a'_`s'_`var'
		estadd scalar mean_below=`land_`a'_`s'_mean': land_c_`a'_`s'_`var'
		estadd scalar sampsi=`land_`a'_`s'_sample': land_c_`a'_`s'_`var'
		estadd scalar bandwidth=`land_`a'_`s'_bw': land_c_`a'_`s'_`var'
			
		if `s'==0{
			rdrobust `var' landsize if bothreportland==1 & male==1, ///
				c(`aplus') h(`l' `r') all
			eststo land_`a'_mf_`var'
			local land_`a'_mf_sample=`n_l'+`n_r'
			local land_`a'_mf_bw=`l'
			sum `var' if landsize<`aplus' & landsize>=`aplus'-`l' & ///
				bothreportland==1 & male==1
			local land_`a'_mf_mean=r(mean)
			rdrandinf `var' landsize if bothreportland==1 & male==1, cutoff(`aplus') wl(`wl') wr(`wr') p(1) kernel(triangular)
			local ri_p=r(randpval)
			estadd scalar mean_below=`land_`a'_mf_mean': land_`a'_mf_`var'
			estadd scalar sampsi=`land_`a'_mf_sample': land_`a'_mf_`var'
			estadd scalar bandwidth=`land_`a'_mf_bw': land_`a'_mf_`var'
			estadd scalar randinf=`ri_p': land_`a'_mf_`var'
		}
	}
}

esttab land_10_0_* using ///
	"$latex/rddland.tex", replace star(* 0.1 ** 0.05 *** 0.01) ///
	cells(b(star fmt(3)) se(par(`"("' `")"') fmt(3))) nocons label ///
	stats(randinf mean_below sampsi bandwidth, fmt(3 3 0 3) ///
	labels("RI p-Value" "Control Mean" "Observations" "Bandwidth")) ///
	booktabs noobs nonotes collabels(none) gaps f ///
	mtitle("\shortstack{Number of\\Plots with\\nonmissing\\plot size}" ///
	"\shortstack{Total num.\\of Form 7s\\in HH}" ///
	"\shortstack{Household has at\\least 1 Form 7\\in Wife's\\name (joint)}" ///
	"\shortstack{HH has at least\\1 Form 7 in\\Wife's\\name (excl. and\\no other man)}") ///
	varlabels(Robust "\textbf{Above 10 Acres}") drop(Conventional Bias-corrected) ///
	alignment(D{.}{.}{-1}) compress


********************************
** Table 4: RDD Loan Outcomes **
********************************

# delimit ;
local loanvars
	loan_num_fem
	loan_num_male;
# delimit cr

foreach var in `loanvars'{
	forval s=0/1{
		
		replace `var'=. if mi(`var')
		
		rdrobust `var' landsize if bothreportland==1 & ///
		male==`s', c(`aplus') all
		local n_l=e(N_h_l)
		local n_r=e(N_h_r)
		local l=e(h_l)
		local r=e(h_r)
		local wl=`aplus'-`l'
		local wr=`aplus'+`r'
		eststo loan_`a'_`s'_`var'
		sum `var' if landsize<`aplus' & landsize>=`aplus'-`l' & ///
			bothreportland==1 & male==`s'
		local loan_`a'_`s'_mean=r(mean)
		local loan_`a'_`s'_sample=`n_l'+`n_r'
		local loan_`a'_`s'_bw=`l'
		rdrandinf `var' landsize if bothreportland==1 & male==`s', cutoff(`aplus') wl(`wl') wr(`wr') p(1) kernel(triangular)
		local ri_p=r(randpval)
		estadd scalar mean_below=`loan_`a'_`s'_mean': loan_`a'_`s'_`var'
		estadd scalar sampsi=`loan_`a'_`s'_sample': loan_`a'_`s'_`var'
		estadd scalar bandwidth=`loan_`a'_`s'_bw': loan_`a'_`s'_`var'
		estadd scalar randinf=`ri_p': loan_`a'_`s'_`var'

		rdrobust `var' landsize if bothreportland==1 & ///
			male==`s', c(`aplus') covs(educ3 hh_size) all
		eststo loan_c_`a'_`s'_`var'
		estadd scalar mean_below=`loan_`a'_`s'_mean': loan_c_`a'_`s'_`var'
		estadd scalar sampsi=`loan_`a'_`s'_sample': loan_c_`a'_`s'_`var'
		estadd scalar bandwidth=`loan_`a'_`s'_bw': loan_c_`a'_`s'_`var'

		if `s'==0{
			rdrobust `var' landsize if bothreportland==1 & male==1, ///
				c(`aplus') h(`l' `r') all
			eststo loan_`a'_mf_`var'
			local loan_`a'_mf_sample=`n_l'+`n_r'
			local loan_`a'_mf_bw=`l'
			sum `var' if landsize<`aplus' & landsize>=`aplus'-`l' & ///
				bothreportland==1 & male==1
			local loan_`a'_mf_mean=r(mean)
			rdrandinf `var' landsize if bothreportland==1 & male==1, cutoff(`aplus') wl(`wl') wr(`wr') p(1) kernel(triangular)
			local ri_p=r(randpval)
			estadd scalar mean_below=`loan_`a'_mf_mean': loan_`a'_mf_`var'
			estadd scalar sampsi=`loan_`a'_mf_sample': loan_`a'_mf_`var'
			estadd scalar bandwidth=`loan_`a'_mf_bw': loan_`a'_mf_`var'
			estadd scalar randinf=`ri_p': loan_`a'_mf_`var'
		}
	}
}

	
************************************
** Table 5: RDD Economic Outcomes **
************************************

# delimit ;
local econvars
	aginc_fem_ln
	nai_f_ln
	aginc_ln;
# delimit cr

foreach var in `econvars'{
	forval s=0/1{
		
		replace `var'=. if mi(`var')
		
		rdrobust `var' landsize if bothreportland==1 & ///
		male==`s', c(`aplus') all
		local n_l=e(N_h_l)
		local n_r=e(N_h_r)
		local l=e(h_l)
		local r=e(h_r)
		local wl=`aplus'-`l'
		local wr=`aplus'+`r'
		eststo econ_`a'_`s'_`var'
		sum `var' if landsize<`aplus' & landsize>=`aplus'-`l' & ///
			bothreportland==1 & male==`s'
		local econ_`a'_`s'_mean=r(mean)
		local econ_`a'_`s'_sample=`n_l'+`n_r'
		local econ_`a'_`s'_bw=`l'
		rdrandinf `var' landsize if bothreportland==1 & male==`s', cutoff(`aplus') wl(`wl') wr(`wr') p(1) kernel(triangular)
		local ri_p=r(randpval)
		estadd scalar mean_below=`econ_`a'_`s'_mean': econ_`a'_`s'_`var'
		estadd scalar sampsi=`econ_`a'_`s'_sample': econ_`a'_`s'_`var'
		estadd scalar bandwidth=`econ_`a'_`s'_bw': econ_`a'_`s'_`var'
		estadd scalar randinf=`ri_p': econ_`a'_`s'_`var'
		
		rdrobust `var' landsize if bothreportland==1 & ///
			male==`s', c(`aplus') covs(educ3 hh_size) all
		eststo econ_c_`a'_`s'_`var'
		estadd scalar mean_below=`econ_`a'_`s'_mean': econ_c_`a'_`s'_`var'
		estadd scalar sampsi=`econ_`a'_`s'_sample': econ_c_`a'_`s'_`var'
		estadd scalar bandwidth=`econ_`a'_`s'_bw': econ_c_`a'_`s'_`var'
		
		if `s'==0{
			rdrobust `var' landsize if bothreportland==1 & male==1, ///
				c(`aplus') h(`l' `r') all
			eststo econ_`a'_mf_`var'
			local econ_`a'_mf_sample=`n_l'+`n_r'
			local econ_`a'_mf_bw=`l'
			sum `var' if landsize<`aplus' & landsize>=`aplus'-`l' & ///
				bothreportland==1 & male==1
			local econ_`a'_mf_mean=r(mean)
			rdrandinf `var' landsize if bothreportland==1 & male==1, cutoff(`aplus') wl(`wl') wr(`wr') p(1) kernel(triangular)
			local ri_p=r(randpval)
			estadd scalar mean_below=`econ_`a'_mf_mean': econ_`a'_mf_`var'
			estadd scalar sampsi=`econ_`a'_mf_sample': econ_`a'_mf_`var'
			estadd scalar bandwidth=`econ_`a'_mf_bw': econ_`a'_mf_`var'
			estadd scalar randinf=`ri_p': econ_`a'_mf_`var'
		}
	}
}

esttab loan_10_0_* econ_10_0_* using ///
	"$latex/rddecon.tex", replace star(* 0.1 ** 0.05 *** 0.01) ///
	cells(b(star fmt(3)) se(par(`"("' `")"') fmt(3))) nocons label ///
	stats(randinf mean_below sampsi bandwidth, fmt(3 3 0 3) ///
	labels("RI p-Value" "Control Mean" "Observations" "Bandwidth")) ///
	booktabs noobs nonotes collabels(none) gaps f ///
	mtitle("\shortstack{Number of\\Loans in\\Wife's Name\\(Land\\Collateralized)}" ///
	"\shortstack{Number of\\Loans in\\Husband's Name\\(Land\\Collateralized)}" "\shortstack{Log Total\\Agricultural\\Revenue\\from Plots\\with Wife's\\Name on\\Form 7}" ///
	"\shortstack{Log\\Total non-\\Agricultural\\Income\\from Wife}" ///
	"\shortstack{Log Total\\Agricultural\\Revenue\\from all\\Plots}") varlabels(Robust "\textbf{Above 10 Acres}") drop(Conventional Bias-corrected) ///
	alignment(D{.}{.}{-1}) compress


********************************
** Table 6: RDD Female Agency **
********************************

# delimit ;
local agencyvars1
	a_ag_ind11
	wt_ag_ind1
	hg_ag_ind1
	wha_ag_ind1;
local agencyvars2
	a_ex_ind11
	wt_ex_ind1
	hg_ex_ind1
	wha_ex_ind1;
# delimit cr

foreach var in `agencyvars1'{
	if "`var'"=="a_ag_ind11"{
		forval s=0/1{
			rdrobust `var' landsize if bothreportland==1 & ///
				male==`s', c(`aplus') all
			local n_l=e(N_h_l)
			local n_r=e(N_h_r)
			local l=e(h_l)
			local r=e(h_r)
			local wl=`aplus'-`l'
			local wr=`aplus'+`r'
			eststo agency1_`a'_`s'_`var'
			sum `var' if landsize<`aplus' & landsize>=`aplus'-`l' & ///
				bothreportland==1 & male==`s'
			local agency1_`a'_`s'_mean=r(mean)
			local agency1_`a'_`s'_sample=`n_l'+`n_r'
			local agency1_`a'_`s'_bw=`l'
			rdrandinf `var' landsize if bothreportland==1 & male==`s', cutoff(`aplus') wl(`wl') wr(`wr') p(1) kernel(triangular)
			local ri_p=r(randpval)
			estadd scalar mean_below=`agency1_`a'_`s'_mean': agency1_`a'_`s'_`var'
			estadd scalar sampsi=`agency1_`a'_`s'_sample': agency1_`a'_`s'_`var'
			estadd scalar bandwidth=`agency1_`a'_`s'_bw': agency1_`a'_`s'_`var'
			estadd scalar randinf=`ri_p': agency1_`a'_`s'_`var'
			
			rdrobust `var' landsize if bothreportland==1 & ///
				male==`s', c(`aplus') covs(educ3 hh_size) all
			eststo agency1_c_`a'_`s'_`var'
			estadd scalar mean_below=`agency1_`a'_`s'_mean': agency1_c_`a'_`s'_`var'
			estadd scalar sampsi=`agency1_`a'_`s'_sample': agency1_c_`a'_`s'_`var'
			estadd scalar bandwidth=`agency1_`a'_`s'_bw': agency1_c_`a'_`s'_`var'
		}
	}
	else{
		rdrobust `var' landsize if bothreportland==1 & ///
			male==0, c(`aplus') all
		local n_l=e(N_h_l)
		local n_r=e(N_h_r)
		local l=e(h_l)
		local r=e(h_r)
		local wl=`aplus'-`l'
		local wr=`aplus'+`r'
		eststo agency1_`a'_0_`var'
		sum `var' if landsize<`aplus' & landsize>=`aplus'-`l' & ///
			bothreportland==1 & male==0
		local agency1_`a'_0_mean=r(mean)
		local agency1_`a'_0_sample=`n_l'+`n_r'
		local agency1_`a'_0_bw=`l'
		rdrandinf `var' landsize if bothreportland==1 & male==0, cutoff(`aplus') wl(`wl') wr(`wr') p(1) kernel(triangular)
		local ri_p=r(randpval)
		estadd scalar mean_below=`agency1_`a'_0_mean': agency1_`a'_0_`var'
		estadd scalar sampsi=`agency1_`a'_0_sample': agency1_`a'_0_`var'
		estadd scalar bandwidth=`agency1_`a'_0_bw': agency1_`a'_0_`var'
		estadd scalar randinf=`ri_p': agency1_`a'_0_`var'
		
		rdrobust `var' landsize if bothreportland==1 & ///
			male==0, c(`aplus') covs(educ3 hh_size) all
		eststo agency1_c_`a'_0_`var'
		estadd scalar mean_below=`agency1_`a'_0_mean': agency1_c_`a'_0_`var'
		estadd scalar sampsi=`agency1_`a'_0_sample': agency1_c_`a'_0_`var'
		estadd scalar bandwidth=`agency1_`a'_0_bw': agency1_c_`a'_0_`var'
	}
}

esttab agency1_10_* using ///
	"$latex/rddagency1.tex", replace star(* 0.1 ** 0.05 *** 0.01) ///
	cells(b(star fmt(3)) se(par(`"("' `")"') fmt(3))) nocons label ///
	stats(randinf mean_below sampsi bandwidth, fmt(3 3 0 3) ///
	labels("RI p-Value" "Control Mean" "Observations" "Bandwidth")) ///
	booktabs noobs nonotes collabels(none) gaps f ///
	mtitle("\shortstack{Index of\\Women's\\Agency in\\Agricultural\\Decisions,\\Wife's\\Response}" ///
	"\shortstack{Index of\\Women's\\Agency in\\Agricultural\\Decisions,\\Husband's\\Response}" ///
	"\shortstack{Agricultural\\Decisions\\index:\\Wife\\takes power}" ///
	"\shortstack{Agricultural\\Decisions\\index:\\Husband\\gives power}" ///
	"\shortstack{Agricultural\\Decisions\\index:\\Wife and\\husband\\agree}") ///
	varlabels(Robust "\textbf{Above 10 Acres}") drop(Conventional Bias-corrected) ///
	alignment(D{.}{.}{-1}) compress

foreach var in `agencyvars2'{
	if "`var'"=="a_ex_ind11"{
		forval s=0/1{
			rdrobust `var' landsize if bothreportland==1 & ///
				male==`s', c(`aplus') all
			local n_l=e(N_h_l)
			local n_r=e(N_h_r)
			local l=e(h_l)
			local r=e(h_r)
			local wl=`aplus'-`l'
			local wr=`aplus'+`r'
			eststo agency2_`a'_`s'_`var'
			sum `var' if landsize<`aplus' & landsize>=`aplus'-`l' & ///
				bothreportland==1 & male==`s'
			local agency2_`a'_`s'_mean=r(mean)
			local agency2_`a'_`s'_sample=`n_l'+`n_r'
			local agency2_`a'_`s'_bw=`l'
			rdrandinf `var' landsize if bothreportland==1 & male==`s', cutoff(`aplus') wl(`wl') wr(`wr') p(1) kernel(triangular)
			local ri_p=r(randpval)
			estadd scalar mean_below=`agency2_`a'_`s'_mean': agency2_`a'_`s'_`var'
			estadd scalar sampsi=`agency2_`a'_`s'_sample': agency2_`a'_`s'_`var'
			estadd scalar bandwidth=`agency2_`a'_`s'_bw': agency2_`a'_`s'_`var'
			estadd scalar randinf=`ri_p': agency2_`a'_`s'_`var'
		}
	}
	else{
		rdrobust `var' landsize if bothreportland==1 & ///
			male==0, c(`aplus') all
		local n_l=e(N_h_l)
		local n_r=e(N_h_r)
		local l=e(h_l)
		local r=e(h_r)
		local wl=`aplus'-`l'
		local wr=`aplus'+`r'
		eststo agency2_`a'_0_`var'
		sum `var' if landsize<`aplus' & landsize>=`aplus'-`l' & ///
			bothreportland==1 & male==0
		local agency2_`a'_0_mean=r(mean)
		local agency2_`a'_0_sample=`n_l'+`n_r'
		local agency2_`a'_0_bw=`l'
		rdrandinf `var' landsize if bothreportland==1 & male==0, cutoff(`aplus') wl(`wl') wr(`wr') p(1) kernel(triangular)
		local ri_p=r(randpval)
		estadd scalar mean_below=`agency2_`a'_0_mean': agency2_`a'_0_`var'
		estadd scalar sampsi=`agency2_`a'_0_sample': agency2_`a'_0_`var'
		estadd scalar bandwidth=`agency2_`a'_0_bw': agency2_`a'_0_`var'
		estadd scalar randinf=`ri_p': agency2_`a'_0_`var'
	}
}

esttab agency2_10_* using ///
	"$latex/rddagency2.tex", replace star(* 0.1 ** 0.05 *** 0.01) ///
	cells(b(star fmt(3)) se(par(`"("' `")"') fmt(3))) nocons label ///
	stats(randinf mean_below sampsi bandwidth, fmt(3 3 0 3) ///
	labels("RI p-Value" "Control Mean" "Observations" "Bandwidth")) ///
	booktabs noobs nonotes collabels(none) gaps f ///
	mtitle("\shortstack{Index of\\Women's\\Agency in\\Expenditure\\Decisions,\\Wife's\\Response}" ///
	"\shortstack{Index of\\Women's\\Agency in\\Expenditure\\Decisions,\\Husband's\\Response}" ///
	"\shortstack{Expenditure\\Decisions\\index:\\Wife\\takes power}" ///
	"\shortstack{Expenditure\\Decisions\\index:\\Husband\\gives power}" ///
	"\shortstack{Expenditure\\Decisions\\index:\\Wife and\\husband\\agree}") ///
	varlabels(Robust "\textbf{Above 10 Acres}") drop(Conventional Bias-corrected) ///
	alignment(D{.}{.}{-1}) compress


*********************************
** Table 7: Political Outcomes **
*********************************

# delimit ;
local polivars
	pknow_min_c
	pknow_vta_c
	voteint_nat
	dem_pref
	demo_satisfy;
# delimit cr

foreach var in `polivars'{
	forval s=0/1{
		
		replace `var'=. if mi(`var')
		
		rdrobust `var' landsize if bothreportland==1 & ///
			male==`s', c(`aplus') all
		local n_l=e(N_h_l)
		local n_r=e(N_h_r)
		local l=e(h_l)
		local r=e(h_r)
		local wl=`aplus'-`l'
		local wr=`aplus'+`r'
		eststo poli_`a'_`s'_`var'
		sum `var' if landsize<`aplus' & landsize>=`aplus'-`l' & ///
			bothreportland==1 & male==`s'
		local poli_`a'_`s'_mean=r(mean)
		local poli_`a'_`s'_sample=`n_l'+`n_r'
		local poli_`a'_`s'_bw=`l'
		rdrandinf `var' landsize if bothreportland==1 & male==`s', cutoff(`aplus') wl(`wl') wr(`wr') p(1) kernel(triangular)
		local ri_p=r(randpval)
		estadd scalar mean_below=`poli_`a'_`s'_mean': poli_`a'_`s'_`var'
		estadd scalar sampsi=`poli_`a'_`s'_sample': poli_`a'_`s'_`var'
		estadd scalar bandwidth=`poli_`a'_`s'_bw': poli_`a'_`s'_`var'
		estadd scalar randinf=`ri_p': poli_`a'_`s'_`var'
		if `s'==0{
			rdrobust `var' landsize if bothreportland==1 & male==1, ///
				c(`aplus') h(`l' `r') all
			eststo poli_`a'_mf_`var'
			sum `var' if landsize<`aplus' & landsize>=`aplus'-`l' & ///
				bothreportland==1 & male==1
			local poli_`a'_mf_mean=r(mean)
			rdrandinf `var' landsize if bothreportland==1 & male==1, cutoff(`aplus') wl(`wl') wr(`wr') p(1) kernel(triangular)
			local ri_p=r(randpval)
			estadd scalar mean_below=`poli_`a'_mf_mean': poli_`a'_mf_`var'
			estadd scalar sampsi=`poli_`a'_`s'_sample': poli_`a'_mf_`var'
			estadd scalar bandwidth=`poli_`a'_`s'_bw': poli_`a'_mf_`var'
			estadd scalar randinf=`ri_p': poli_`a'_mf_`var'
		}
	}
}

esttab poli_10_0_* using ///
	"$latex/rddpoli.tex", replace star(* 0.1 ** 0.05 *** 0.01) ///
	cells(b(star fmt(3)) se(par(`"("' `")"') fmt(3))) nocons label ///
	stats(randinf mean_below sampsi bandwidth, fmt(3 3 0 3) ///
	labels("RI p-Value" "Control Mean" "Observations" "Bandwidth")) ///
	booktabs noobs nonotes collabels(none) gaps f ///
	mtitle("\shortstack{Name\\CM of\\Ayeyarwaddy\\correctly}" ///
	"\shortstack{Name\\VTA\\correctly}" ///
	"\shortstack{Plan to\\vote in\\upcoming\\National\\election}" ///
	"\shortstack{Dem.\\always\\preferable\\to any\\other gov.}" ///
	"\shortstack{Satisfaction\\with\\democracy\\in Myanmar}") ///
	varlabels(Robust "\textbf{Panel A: Wife}") drop(Conventional Bias-corrected) ///
	alignment(D{.}{.}{-1}) compress

esttab poli_10_mf_* using ///
	"$latex/rddpoli.tex", append star(* 0.1 ** 0.05 *** 0.01) ///
	cells(b(star fmt(3)) se(par(`"("' `")"') fmt(3))) nocons label ///
	stats(randinf mean_below sampsi bandwidth, fmt(3 3 0 3) ///
	labels("RI p-Value" "Control Mean" "Observations" "Bandwidth")) ///
	booktabs noobs nodep nonum nomtitles ///
	nonotes collabels(none) f gaps ///
	varlabels(Robust ///
	"\textbf{Panel B: Husband}") drop(Conventional Bias-corrected) ///
	alignment(D{.}{.}{-1}) compress


******************************
** Table 8: Behavioral Game **
******************************

# delimit ;
local wtpvars
	wtpcash_lb
	wtpcash_ub
	wtpland_lb
	wtpland_ub;
# delimit cr

foreach var in `wtpvars'{
	
	local s=0

	replace `var'=. if mi(`var')
	
	rdrobust `var' landsize if bothreportland==1 & ///
		male==`s', c(`aplus') all
	local n_l=e(N_h_l)
	local n_r=e(N_h_r)
	local l=e(h_l)
	local r=e(h_r)
	local wl=`aplus'-`l'
	local wr=`aplus'+`r'
	eststo wtp_`a'_`s'_`var'
	sum `var' if landsize<`aplus' & landsize>=`aplus'-`l' & ///
		bothreportland==1 & male==`s'
	local wtp_`a'_`s'_mean=r(mean)
	local wtp_`a'_`s'_sample=`n_l'+`n_r'
	local wtp_`a'_`s'_bw=`l'
	rdrandinf `var' landsize if bothreportland==1 & male==`s', cutoff(`aplus') wl(`wl') wr(`wr') p(1) kernel(triangular)
	local ri_p=r(randpval)
	estadd scalar mean_below=`wtp_`a'_`s'_mean': wtp_`a'_`s'_`var'
	estadd scalar sampsi=`wtp_`a'_`s'_sample': wtp_`a'_`s'_`var'
	estadd scalar bandwidth=`wtp_`a'_`s'_bw': wtp_`a'_`s'_`var'
	estadd scalar randinf=`ri_p': wtp_`a'_`s'_`var'
}

esttab wtp_10_0_* using ///
	"$latex/rddwtp.tex", replace star(* 0.1 ** 0.05 *** 0.01) ///
	cells(b(star fmt(3)) se(par(`"("' `")"') fmt(3))) nocons label ///
	stats(randinf mean_below sampsi bandwidth, fmt(3 3 0 3) ///
	labels("RI p-Value" "Control Mean" "Observations" "Bandwidth")) ///
	booktabs noobs nonotes collabels(none) gaps f ///
	mtitle("\shortstack{Amount\\Willing\\to Accept\\for Autonomy\\in Cash\\Game (Min)}" ///
	"\shortstack{Amount\\Willing\\to Accept\\for Autonomy\\in Cash\\Game (Max)}" ///
	"\shortstack{Amount\\Willing\\to Accept\\for Autonomy\\in Land\\Game (Min)}" ///
	"\shortstack{Amount\\Willing\\to Accept\\for Autonomy\\in Land\\Game (Max)}") ///
	varlabels(Robust "\textbf{Above 10 Acres}") drop(Conventional Bias-corrected) ///
	alignment(D{.}{.}{-1}) compress
	
	
************************************************
** Table 9: RDD Female Agency (heterogeneity) **
************************************************

***** extend local leader variable to entire village tract
bysort vt: egen lead_min=min(gov_vtaself)
bysort vt: replace gov_couple_decision=. if gov_vtaself==2 & lead_min==1
bysort vt: egen gov_couple_decision_vt=max(gov_couple_decision)
gen norms=inlist(gov_couple_decision_vt, 1, 2)
replace norms=. if mi(gov_couple_decision_vt)

replace gov_role_women=0 if inlist(gov_role_women, .d, .r)
bysort vt: replace gov_role_women=. if gov_vtaself==2 & lead_min==1
bysort vt: egen gov_role_women_vt=max(gov_role_women)
gen norms2=gov_role_women_vt==1
replace norms2=. if mi(gov_role_women_vt)

# delimit ;
local agencyvars1
	a_ag_ind11
	wt_ag_ind1
	hg_ag_ind1
	wha_ag_ind1;
local agencyvars2
	a_ex_ind11
	wt_ex_ind1
	hg_ex_ind1
	wha_ex_ind1;
local hetvars
	norms
	norms2;
# delimit cr

preserve

	local i=1
	foreach het in `hetvars'{
		foreach var in `agencyvars1'{
			if "`var'"=="a_ag_ind11"{
				forval s=0/1{
					rdrobust `var' landsize if bothreportland==1 & ///
						male==`s', c(`aplus') all
				local n_l=e(N_h_l)
				local n_r=e(N_h_r)
				local l=e(h_l)
				local r=e(h_r)
					local wl=`aplus'-`l'
					local wr=`aplus'+`r'
					
					rdrobust `var' landsize if bothreportland==1 & ///
						male==`s' & `het'==0, c(`aplus') h(`l') all
					eststo a1_`i'_`a'_`s'_`var'_0
					local n_ll=e(N_h_l)
					local n_rl=e(N_h_r)
					local l_l=e(h_l)
					local r_l=e(h_r)
					local a1_`a'_`s'_samplel=`n_ll'+`n_rl'
					
					rdrobust `var' landsize if bothreportland==1 & ///
						male==`s' & `het'==1, c(`aplus') h(`l') all
					eststo a1_`i'_`a'_`s'_`var'_1
					local n_lh=e(N_h_l)
					local n_rh=e(N_h_r)
					local l_h=e(h_l)
					local r_h=e(h_r)
					local a1_`a'_`s'_sampleh=`n_lh'+`n_rh'
					
					sum `var' if landsize<`aplus' & landsize>=`aplus'-`l_l' ///
						& bothreportland==1 & male==`s' & `het'==0
					local a1_`a'_`s'_meanl=r(mean)
					sum `var' if landsize<`aplus' & landsize>=`aplus'-`l_h' ///
						& bothreportland==1 & male==`s' & `het'==1
					local a1_`a'_`s'_meanh=r(mean)
					local a1_`a'_`s'_sample=`n_l'+`n_r'
					local a1_`a'_`s'_bw=`l'
					local a1_`a'_`s'_bwl=`l_l'
					local a1_`a'_`s'_bwh=`l_h'
					estadd scalar mean_belowl=`a1_`a'_`s'_meanl': a1_`i'_`a'_`s'_`var'_0
					estadd scalar mean_belowh=`a1_`a'_`s'_meanh': a1_`i'_`a'_`s'_`var'_1
					estadd scalar sampsil=`a1_`a'_`s'_samplel': a1_`i'_`a'_`s'_`var'_0
					estadd scalar sampsih=`a1_`a'_`s'_sampleh': a1_`i'_`a'_`s'_`var'_1
					estadd scalar bandwidthl=`a1_`a'_`s'_bwl': a1_`i'_`a'_`s'_`var'_0
					estadd scalar bandwidthh=`a1_`a'_`s'_bwh': a1_`i'_`a'_`s'_`var'_1
				}
			}
			else{
				rdrobust `var' landsize if bothreportland==1 & ///
					male==0, c(`aplus') all
				local n_l=e(N_h_l)
				local n_r=e(N_h_r)
				local l=e(h_l)
				local r=e(h_r)
				local wl=`aplus'-`l'
				local wr=`aplus'+`r'
				
				rdrobust `var' landsize if bothreportland==1 & ///
						male==0 & `het'==0, c(`aplus') h(`l') all
				eststo a1_`i'_`a'_0_`var'_0
				local n_ll=e(N_h_l)
				local n_rl=e(N_h_r)
				local l_l=e(h_l)
				local r_l=e(h_r)
				local a1_`a'_0_samplel=`n_ll'+`n_rl'
				
				rdrobust `var' landsize if bothreportland==1 & ///
					male==0 & `het'==1, c(`aplus') h(`l') all
				eststo a1_`i'_`a'_0_`var'_1
				local n_lh=e(N_h_l)
				local n_rh=e(N_h_r)
				local l_h=e(h_l)
				local r_h=e(h_r)
				local a1_`a'_0_sampleh=`n_lh'+`n_rh'
				
				sum `var' if landsize<`aplus' & landsize>=`aplus'-`l' & ///
					bothreportland==1 & male==0 & `het'==0
				local a1_`a'_0_meanl=r(mean)
				sum `var' if landsize<`aplus' & landsize>=`aplus'-`l' & ///
					bothreportland==1 & male==0 & `het'==1
				local a1_`a'_0_meanh=r(mean)
				local a1_`a'_0_sample=`n_l'+`n_r'
				local a1_`a'_0_bw=`l'
				local a1_`a'_`s'_bwl=`l_l'
				local a1_`a'_`s'_bwh=`l_h'
				estadd scalar mean_belowl=`a1_`a'_0_meanl': a1_`i'_`a'_0_`var'_0
				estadd scalar mean_belowh=`a1_`a'_0_meanh': a1_`i'_`a'_0_`var'_1
				estadd scalar sampsil=`a1_`a'_0_samplel': a1_`i'_`a'_0_`var'_0
				estadd scalar sampsih=`a1_`a'_0_sampleh': a1_`i'_`a'_0_`var'_1
				estadd scalar bandwidthl=`a1_`a'_0_bwl': a1_`i'_`a'_0_`var'_0
				estadd scalar bandwidthh=`a1_`a'_0_bwh': a1_`i'_`a'_0_`var'_1
			}
		}
		local i=`i'+1
	}
	
	local i=1
	local append="replace"
	local mod=""
	local title=`"mtitle("\shortstack{Index of\\Women's\\Agency in\\Agricultural\\Decisions,\\Wife's\\Response}" "\shortstack{Index of\\Women's\\Agency in\\Agricultural\\Decisions,\\Husband's\\Response}" "\shortstack{Agricultural\\Decisions\\index:\\Woman\\takes power}" "\shortstack{Agricultural\\Decisions\\index:\\Husband\\gives power}" "\shortstack{Agricultural\\Decisions\\index:\\Wife and\\husband\\agree}")"'
	foreach het in `hetvars'{

		esttab a1_`i'_10_*_0 using "$latex/rddagency_het.tex", `append' star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par(`"("' `")"') fmt(3))) nocons label stats( mean_belowl sampsil bandwidthl, fmt(3 0 3) labels("Control Mean" "Observations" "Bandwidth")) booktabs noobs `mod' nonotes collabels(none) gaps f `title' varlabels(Robust "\midrule \textbf{`pan`i''} \\ \midrule \textbf{Low `lab`i''}")  drop(Conventional Bias-corrected) alignment(D{.}{.}{-1}) compress nolines
			
		local append="append"
		local mod="nodep nonum nomtitles"
		local title=""
			
		esttab a1_`i'_10_*_1 using "$latex/rddagency_het.tex", `append' star(* 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par(`"("' `")"') fmt(3))) nocons label stats(mean_belowh sampsih bandwidthh, fmt(3 0 3) labels("Control Mean" "Observations" "Bandwidth")) booktabs noobs nodep nonum nomtitles nonotes collabels(none) gaps f varlabels(Robust "\textbf{High `lab`i''}")  drop(Conventional Bias-corrected) alignment(D{.}{.}{-1}) compress nolines
			
		local i=`i'+1
	}
		
restore


************************** Additional Appendix Tables **************************

esttab land_c_10_0_* loan_c_10_0_* econ_c_10_0_* agency1_c_10_* using ///
	"$latex/rdd_appendix1.tex", replace star(* 0.1 ** 0.05 *** 0.01) ///
	cells(b(star fmt(3)) se(par(`"("' `")"') fmt(3))) nocons label ///
	stats(mean_below sampsi bandwidth, fmt(3 0 3) ///
	labels("Control Mean" "Observations" "Bandwidth")) ///
	booktabs noobs nonotes collabels(none) nomtitle gaps f ///
	mgroups("Property Rights" "Economic Outcomes" "Agency in Ag. Decisions", pattern(1 0 0 0 1 0 0 0 0 1 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	varlabels(Robust "\textbf{Above 10 Acres}") drop(Conventional Bias-corrected) ///
	alignment(D{.}{.}{-1}) compress


esttab land_10_mf_* loan_10_mf_* econ_10_mf_* using ///
	"$latex/rdd_appendix2.tex", replace star(* 0.1 ** 0.05 *** 0.01) ///
	cells(b(star fmt(3)) se(par(`"("' `")"') fmt(3))) nocons label ///
	stats(randinf mean_below sampsi bandwidth, fmt(3 3 0 3) ///
	labels("RI p-Value" "Control Mean" "Observations" "Bandwidth")) ///
	booktabs noobs nonotes collabels(none) f gaps ///
	mgroups("Property Rights" "Economic Outcomes", pattern(1 0 0 0 1 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	mtitle("\shortstack{Number of\\Plots with\\nonmissing\\plot size}" ///
	"\shortstack{Total num.\\of Form 7s\\in HH}" ///
	"\shortstack{Household has at\\least 1 Form 7\\in Wife's\\name (joint)}" ///
	"\shortstack{HH has at least\\1 Form 7 in\\Wife's\\name (excl. and\\no other man)}" "\shortstack{Number of\\Loans in\\Wife's Name\\(Land\\Collateralized)}" ///
	"\shortstack{Number of\\Loans in\\Husband's Name\\(Land\\Collateralized)}" "\shortstack{Log Total\\Agricultural\\Revenue\\from Plots\\with Wife's\\Name on\\Form 7}" ///
	"\shortstack{Log \\Total non-\\Agricultural\\Income\\from\\Wife}" ///
	"\shortstack{Log Total\\Agricultural\\Revenue\\from all\\Plots}") ///
	alignment(D{.}{.}{-1}) compress


*********************************** RD PLOTS ***********************************


# delimit ;
local econvars
	loan_num_fem
	loan_num_male
	aginc_fem_ln
	nai_f_ln
	aginc_ln;
# delimit cr

# delimit ;
local varcat
	balvars
	landvars
	econvars
	agencyvars1
	agencyvars2;
# delimit cr

label var a_ag_ind11 "Index of Women's Agency in Agricultural Decisions"
label var a_ex_ind11 "Index of Women's Agency in Expenditure Decisions"
label var aginc_fem_ln "Log of Ag. Rev. from Plots w/Wife's name on Form 7"
label var nai_f_ln "Log of non-Ag. Income from Wife"
label var form7_femhoh "HH has at least 1 Form 7 in Wife's name (joint)"
label var f7_fhoh_nm "HH has >= 1 F7 in Wife's name (excl., no man)"
label var wtpcash_lb "Min. Amt. Willing to Accept for Autonomy in Cash Game"
label var wtpcash_ub "Max. Amt. Willing to Accept for Autonomy in Cash Game"
label var wtpland_lb "Min. Amt. Willing to Accept for Autonomy in Land Game"
label var wtpland_ub "Max. Amt. Willing to Accept for Autonomy in Land Game"
label var loan_num_fem "Number of Loans in Wife's Name"
label var loan_num_male "Number of Loans in Husband's Name"
label var pknow_min_c "Name CM of Ayeyarwaddy Correctly"
label var pknow_vta_c "Name VTA Correctly"
label var voteint_nat "Plan to vote in upcoming Nat. Election"
label var dem_pref "Dem. always pref. to any other Gov."
label var demo_satisfy "Satisfaction with Democracy in Myanmar"
label var educ1 "Resp. has less than Primary Edu."
label var educ2 "Resp. has >= Prim. but < Sec. Edu."
label var educ3 "Resp. has at least Secondary Educ."

local y: variable label landsize
local xtitle="`y'"

local landvars_f_l_ytitle1="Conditional Mean (Linear)"
local landvars_f_l_ytitle2=""
local landvars_f_l_ytitle3="Conditional Mean (Linear)"
local landvars_f_l_ytitle4=""
local landvars_f_q_ytitle1="Conditional Mean (Quadratic)"
local landvars_f_q_ytitle2=""
local landvars_f_q_ytitle3="Conditional Mean (Quadratic)"
local landvars_f_q_ytitle4=""
local landvars_f_xtitle1=""
local landvars_f_xtitle2=""
local landvars_f_xtitle3="`xtitle'"
local landvars_f_xtitle4="`xtitle'"

local agencyvars1_f_l_ytitle1="Conditional Mean (Linear)"
local agencyvars1_f_l_ytitle2=""
local agencyvars1_f_l_ytitle3="Conditional Mean (Linear)"
local agencyvars1_f_l_ytitle4=""
local agencyvars1_f_q_ytitle1="Conditional Mean (Quadratic)"
local agencyvars1_f_q_ytitle2=""
local agencyvars1_f_q_ytitle3="Conditional Mean (Quadratic)"
local agencyvars1_f_q_ytitle4=""
local agencyvars1_f_xtitle1=""
local agencyvars1_f_xtitle2=""
local agencyvars1_f_xtitle3="`xtitle'"
local agencyvars1_f_xtitle4="`xtitle'"

local agencyvars2_f_l_ytitle1="Conditional Mean (Linear)"
local agencyvars2_f_l_ytitle2=""
local agencyvars2_f_l_ytitle3="Conditional Mean (Linear)"
local agencyvars2_f_l_ytitle4=""
local agencyvars2_f_q_ytitle1="Conditional Mean (Quadratic)"
local agencyvars2_f_q_ytitle2=""
local agencyvars2_f_q_ytitle3="Conditional Mean (Quadratic)"
local agencyvars2_f_q_ytitle4=""
local agencyvars2_f_xtitle1=""
local agencyvars2_f_xtitle2=""
local agencyvars2_f_xtitle3="`xtitle'"
local agencyvars2_f_xtitle4="`xtitle'"

local econvars_f_l_ytitle1="Conditional Mean (Linear)"
local econvars_f_l_ytitle2=""
local econvars_f_l_ytitle3=""
local econvars_f_l_ytitle4="Conditional Mean (Linear)"
local econvars_f_l_ytitle5=""
local econvars_f_q_ytitle1="Conditional Mean (Quadratic)"
local econvars_f_q_ytitle2=""
local econvars_f_q_ytitle3=""
local econvars_f_q_ytitle4="Conditional Mean (Quadratic)"
local econvars_f_q_ytitle5=""
local econvars_f_xtitle1="-"
local econvars_f_xtitle2="-"
local econvars_f_xtitle3="`xtitle'"
local econvars_f_xtitle4="`xtitle'"
local econvars_f_xtitle5="`xtitle'"

local balvars_f_l_ytitle1="Conditional Mean (Linear)"
local balvars_f_l_ytitle2=""
local balvars_f_l_ytitle3=""
local balvars_f_l_ytitle4="Conditional Mean (Linear)"
local balvars_f_l_ytitle5=""
local balvars_f_q_ytitle1="Conditional Mean (Quadratic)"
local balvars_f_q_ytitle2=""
local balvars_f_q_ytitle3=""
local balvars_f_q_ytitle4="Conditional Mean (Quadratic)"
local balvars_f_q_ytitle5=""
local balvars_f_xtitle1="-"
local balvars_f_xtitle2="-"
local balvars_f_xtitle3="`xtitle'"
local balvars_f_xtitle4="`xtitle'"
local balvars_f_xtitle5="`xtitle'"


foreach cat of local varcat{
	local i=1
	foreach var in ``cat''{
		local y: variable label `var'
		cmogram `var' landsize if bothreportland==1 & male==0 ///
			& landsize>=0 & landsize<=20, cutpoint(`aplus') ///
			scatter qfitci lfitopts(level(90)) graphopts(xline(`aplus') ///
			xtitle("``cat'_f_xtitle`i''") ///
			ytitle("``cat'_f_q_ytitle`i''") ///
			title("`y'", size(small)))
		graph rename _graph0 quad_`i'_f
		
		local i=`i'+1
		estimates clear
	}
	
	if "`cat'"=="landvars"{
		foreach g in "quad"{
			graph combine `g'_1_f `g'_2_f `g'_3_f `g'_4_f
			graph export "$latex/`g'_plot_`cat'_f.png", replace
		}
	}
	else if "`cat'"=="agencyvars1" | "`cat'"=="agencyvars2"{
		foreach g in "quad"{
			graph combine `g'_1_f `g'_2_f `g'_3_f `g'_4_f
			graph export "$latex/`g'_plot_`cat'_f.png", replace
		}
	}

	else if "`cat'"=="econvars"{
		foreach g in "quad"{
			graph combine `g'_1_f `g'_2_f `g'_3_f `g'_4_f `g'_5_f
			graph export "$latex/`g'_plot_`cat'_f.png", replace
		}
	}

	else if "`cat'"=="balvars"{
		foreach g in "quad"{
			graph combine `g'_1_f `g'_2_f `g'_3_f `g'_4_f `g'_5_f
			graph export "$latex/`g'_plot_`cat'_f.png", replace
		}
	}
	graph drop quad_*
}


********************************* COEFF PLOTS **********************************

# delimit ;
local varcat
	landvars
	econvars
	agencyvars1
	agencyvars2;
# delimit cr

local landvars_f_ytitle1="Effect Size"
local landvars_f_ytitle2=""
local landvars_f_ytitle3="Effect Size"
local landvars_f_ytitle4=""
local landvars_f_xtitle1=""
local landvars_f_xtitle2=""
local landvars_f_xtitle3="RD Cutoff (Acres)"
local landvars_f_xtitle4="RD Cutoff (Acres)"

local agencyvars1_f_ytitle1="Effect Size"
local agencyvars1_f_ytitle2=""
local agencyvars1_f_ytitle3="Effect Size"
local agencyvars1_f_ytitle4=""
local agencyvars1_f_xtitle1=""
local agencyvars1_f_xtitle2=""
local agencyvars1_f_xtitle3="RD Cutoff (Acres)"
local agencyvars1_f_xtitle4="RD Cutoff (Acres)"

local agencyvars2_f_ytitle1="Effect Size"
local agencyvars2_f_ytitle2=""
local agencyvars2_f_ytitle3="Effect Size"
local agencyvars2_f_ytitle4=""
local agencyvars2_f_xtitle1=""
local agencyvars2_f_xtitle2=""
local agencyvars2_f_xtitle3="RD Cutoff (Acres)"
local agencyvars2_f_xtitle4="RD Cutoff (Acres)"

local econvars_f_ytitle1="Effect Size"
local econvars_f_ytitle2=""
local econvars_f_ytitle3=""
local econvars_f_ytitle4="Effect Size"
local econvars_f_ytitle5=""
local econvars_f_xtitle1=" "
local econvars_f_xtitle2=" "
local econvars_f_xtitle3="RD Cutoff (Acres)"
local econvars_f_xtitle4="RD Cutoff (Acres)"
local econvars_f_xtitle5="RD Cutoff (Acres)"


* Make coefficient plots

foreach cat of local varcat{
	local i=1
	foreach var in ``cat''{
		local y: variable label `var'
		forval a=5/15{
			
			local aplus=`a'+.00000000000001
			
			rdrobust `var' landsize if bothreportland==1 & male==0, c(`aplus') all
			eststo coeff_`var'_0_`a'
		}
		coefplot (coeff_`var'_0_5, mlabel("5") mcolor(gray) mlabcolor(gray) ciopts(lcolor(gray)) levels(90) keep(Robust)) ///
			(coeff_`var'_0_6, mlabel("6") mcolor(gray) mlabcolor(gray) ciopts(lcolor(gray)) levels(90) keep(Robust)) ///
			(coeff_`var'_0_7, mlabel("7") mcolor(gray) mlabcolor(gray) ciopts(lcolor(gray)) levels(90) keep(Robust)) ///
			(coeff_`var'_0_8, mlabel("8") mcolor(gray) mlabcolor(gray) ciopts(lcolor(gray)) levels(90) keep(Robust)) ///
			(coeff_`var'_0_9, mlabel("9") mcolor(gray) mlabcolor(gray) ciopts(lcolor(gray)) levels(90) keep(Robust)) ///
			(coeff_`var'_0_10, mlabel("10") mcolor(orange_red) mlabcolor(orange_red) ciopts(lcolor(orange_red) lwidth(thick)) levels(90) keep(Robust)) ///
			(coeff_`var'_0_11, mlabel("11") mcolor(gray) mlabcolor(gray) ciopts(lcolor(gray)) levels(90) keep(Robust)) ///
			(coeff_`var'_0_12, mlabel("12") mcolor(gray) mlabcolor(gray) ciopts(lcolor(gray)) levels(90) keep(Robust)) ///
			(coeff_`var'_0_13, mlabel("13") mcolor(gray) mlabcolor(gray) ciopts(lcolor(gray)) levels(90) keep(Robust)) ///
			(coeff_`var'_0_14, mlabel("14") mcolor(gray) mlabcolor(gray) ciopts(lcolor(gray)) levels(90) keep(Robust)) ///
			(coeff_`var'_0_15, mlabel("15") mcolor(gray) mlabcolor(gray) ciopts(lcolor(gray)) levels(90) keep(Robust)), ///
			vertical xtitle("``cat'_f_xtitle`i''") ///
			xlabel(, nolabels noticks) ///
			ytitle("``cat'_f_ytitle`i''") title("`y'", ///
			size(small)) yline(0) legend(off) scheme(s1color)
		graph rename Graph coeff_`i'_f
		
		local i=`i'+1
		estimates clear
	}
	if "`cat'"=="landvars"{
		graph combine coeff_1_f coeff_2_f coeff_3_f coeff_4_f
		graph export "$latex/coef_plot_`cat'_f.png", replace
	}
	else if "`cat'"=="agencyvars1" | "`cat'"=="agencyvars2"{
		graph combine coeff_1_f coeff_2_f coeff_3_f coeff_4_f
		graph export "$latex/coef_plot_`cat'_f.png", replace
	}
	
	else if "`cat'"=="econvars"{
		graph combine coeff_1_f coeff_2_f coeff_3_f coeff_4_f coeff_5_f
		graph export "$latex/coef_plot_`cat'_f.png", replace
	}

	graph drop coeff_*
}